﻿@using ZX.Model
@using ZX.Tools
@model Document_Manager
@{
    ViewBag.Title = "文档编辑-指效OA";
}
<link href="~/Static/styles/theme/default/all.css" rel="stylesheet" />
<link href="~/Static/styles/theme/zui/css/min.css" rel="stylesheet" />
<link href="~/Static/js/jquery/chosen/chosen.min.css" rel="stylesheet" />
<link href="~/Static/js/layui/css/layui.css" rel="stylesheet" />
<link href="/Static/styles/bootstrap.min.css" rel="stylesheet" />
<link href="~/Static/js/layer/need/layer.css" rel="stylesheet" />
<script src="/Static/js/jquery/jquery-1.11.1.min.js"></script>
<script src="/Static/js/jquery/form/min.js"></script>
<script src="~/Static/js/Validform_v5.3.2_min.js"></script>
<script src="~/Static/js/jquery/chosen/chosen.min.js"></script>
<script src="~/Static/js/zui/zui.min.js"></script>
<script src="~/Static/js/layui/layui.js"></script>
<script src="~/Static/js/layer/layer.js"></script>
<script src="~/Static/js/layer/layer.tools.js"></script>
<script language='javascript'>
    $("body").children("div[class='container']").attr("class", "m-company-setbasic");
</script>
<div id="sysDTypeTree" class="menuContent" style="display: none; position: absolute;">
    <ul id="treeDocType" class="ztree" style="margin-top: 0;"></ul>
</div>

<input type="hidden" id="txtDTypeTree" value="@ViewBag.TreeJson" />
<input type="hidden" id="currentMid" value="@ViewBag.CurrentMid">
<input type="hidden" id="isPrivate" value="@ViewBag.IsPrivate">
<input type="hidden" id="secondMenuId" name="secondMenuId" value="@ViewBag.SecondMenuId" />

@Html.Raw(ViewBag.SysAdminMainNavbar)
<div class='row page-content'>
    <nav id='menu'>
        <ul class='nav'>
            <li>
                <a href='javascript:;'>@Model.DTitle</a>
            </li>
            <li class='divider angle'></li>
        </ul>
    </nav>
    <div class='panel with-menu page-content' style="float:left">
        <div class='panel-heading'>
            <strong><small class='text-muted'><i class='icon icon-plus'></i></small> 创建文档</strong>
        </div>
        <div class='panel-body'>
            <form class="form-horizontal" method='post' id='ajaxForm' action="SaveData">
                <input type="hidden" id="FK_TypeId" name="FK_TypeId" value="@ViewBag.FK_TypeId">
                <input type="hidden" id="Id" name="Id" value="@Model.Id">
                <div class="form-group">
                    <label for="FK_TypeId" class="col-sm-2">
                        分类
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <div class="input-group">
                            <input type='text' placeholder='类目' id='txtDTypeParent' value='@(ViewBag.DTypeName ?? "顶级")' class='form-control' readonly='readonly' onclick='showSysDocTypeTree()' />
                            <label class="input-group-addon">
                                @{
                                    if (ViewBag.IsPrivate == 1)
                                    {
                                        <input type="checkbox" name="IsPrivate" disabled value="@ViewBag.IsPrivate" id="IsPrivate" checked>
                                    }
                                    else
                                    {
                                        <input type="checkbox" name="IsPrivate" disabled value="@ViewBag.IsPrivate" id="IsPrivate">
                                    }
                                }

                            </label>
                            <span class="input-group-addon">设为私密</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="DTitle" class="col-sm-2">
                        文档名称
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="text" id="DTitle" name="DTitle" value="@Model.DTitle" placeholder="名称" class="form-control">
                    </div>
                </div>
                <div id="div_Attach" class="form-group">
                    <label for="Attach" class="col-sm-2">
                        文档
                    </label>
                    <div class="col-md-10 col-sm-10">
                        <input type="hidden" name="Attach" id="Attach" value="@Model.Attach" />
                        <button type="button" class="layui-btn" id="btnUpload">上传</button>
                        <label id="lblAttach">@Model.Attach</label>
                        @{
                            if (Model.Attach.IsNotNullOrEmpty())
                            {
                                <a href="@Model.Attach">下载文档</a>
                            }
                            else
                            {
                                <label>暂无文档</label>
                            }
                        }
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        @Html.Raw(ViewBag.CurrentBtnList29)
                        <a href='javascript:history.go(-1);' class='btn btn-back '>返回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script language='javascript'>

    $(function () {
        layui.use('upload', function () {
            var upload = layui.upload;
            var uploadInst1 = upload.render({
                elem: '#btnUpload'
                , url: '/upload/UploadAttach'
                , accept: 'file'
                , data: { direName: "/Doc/Files" }
                , done: function (res) {
                    $("#Attach").val(res.Data);
                    $("#lblAttach").text(res.Data);
                }
                , error: function (res) {
                    win.alert(JSON.stringify(res));
                }
            });
        });
    });

    function saveData() {
        $("#ajaxForm").submit();
    }

    $("#ajaxForm").Validform({
        tiptype: 3,
        callback: function (form) {
            $("#ajaxForm").ajaxSubmit(function (data) {
                if (data.Code == 300) {
                    win.alert(data.Message);
                } else if (data.Code == 200) {
                    win.success("保存成功", function () {
                    });
                }
            });
            return false;
        }
    });
</script>
